{include file="public/com_header"}

<body style="padding:10px;">
  <div class="tplay-body-div">
    <div class="layui-tab">
      <ul class="layui-tab-title">
        <li class="layui-this">URL美化管理</li>
        <li><a href="{:url('admin/urlsconfig/publish')}" class="a_menu">新增美化</a></li>
      </ul>
    </div>
    <table class="layui-table" lay-size="sm">
      <colgroup>
        <col width="50">
        <col width="150">
        <col width="100">
        <col width="350">
        <col width="150">
        <col width="100">
        <col width="100">
      </colgroup>
      <thead>
        <tr>
          <th>编号</th>
          <th>美化前</th>
          <th>美化后</th>
          <th>备注</th>
          <th>创建时间</th>
          <th>状态</th>
          <th>操作</th>
        </tr> 
      </thead>
      <tbody>
        {volist name="urlconfig" id="vo"}
        <tr>
          <td>{$vo.id}</td>
          <td>{$vo.url}</td>
          <td>{$vo.aliases}</td>
          <td>{$vo.desc}</td>
          <td>{$vo.create_time}</td>
          <td>{if condition="$vo.status eq 1"}<span class="layui-badge">启用</span>{else /}<span class="layui-badge layui-bg-gray">禁用</span>{/if}</td>
          <td class="operation-menu">
            <div class="layui-btn-group">
              <a class="layui-btn layui-btn-xs a_menu layui-btn-primary" href="{:url('admin/urlsconfig/publish',['id'=>$vo.id])}" style="margin-right: 0;font-size:12px;"><i class="layui-icon"></i></a>
              <a class="layui-btn layui-btn-xs layui-btn-primary status" {if condition="$vo.status eq 1"}data-id="0"{else /}data-id="1"{/if} id="{$vo.id}" style="margin-right: 0;font-size:12px;" ><i class="fa {if condition="$vo.status eq 1"}fa-toggle-on{else /}fa-toggle-off{/if}"></i></a>
              <a class="layui-btn layui-btn-xs delete layui-btn-primary" id="{$vo.id}" style="margin-right: 0;font-size:12px;"><i class="layui-icon"></i></a>
            </div>
          </td>
        </tr>
        {/volist}
      </tbody>
    </table>
    <div style="padding:0 20px;">{$urlconfig->render()}</div>
            
    {include file="public/foot"}
    <script type="text/javascript">

    $('.delete').click(function(){
      var id = $(this).attr('id');
      layer.confirm('确定要删除?', function(index) {
        $.ajax({
          url:"{:url('admin/urlsconfig/delete')}",
          data:{id:id},
          success:function(res) {
            layer.msg(res.msg);
            if(res.code == 1) {
              setTimeout(function(){
                location.href = res.url;
              },1500)
            }
          }
        })
      })
    })

    </script>

    <script type="text/javascript">
    layui.use('layer', function(){
      var layer = layui.layer;
      

      $('.status').click(function(){
        var id = $(this).attr('id');
        var status = $(this).attr('data-id');
        layer.confirm('确定要设置?', function(index) {
          $.ajax({
            url:"{:url('admin/urlsconfig/status')}",
            type:'post',
            data:{id:id,status:status},
            success:function(res) {
              layer.msg(res.msg);
              if(res.code == 1) {
                setTimeout(function(){
                  location.href = res.url;
                },1500)
              }
            }
          })
        })
      }) 

    }); 
    </script>
  </div>
</body>
</html>
